#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "win_qextserialport.h"

class QShortcut;
class QRadioButton;

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    void changeEvent(QEvent *e);

private slots:
    void on_sendMsgLineEditComboBox_returnPressed();
    void on_sendMsgBtn_clicked();
    void on_closeMyComBtn_clicked();
    void on_openMyComBtn_clicked();
    void on_pushButton_clicked();
    void readMyCom();
	void openFindDialog();
	void findText();
	void ftpResult(int id);
	void mailTo(const QString& address);

private:
	enum DATADISPLAY
	{
		DDY_NONE = 0,
		DDY_TEXT,
		DDY_HEX
	};
    Ui::MainWindow *ui;
    Win_QextSerialPort *myCom;
	QShortcut* openFindDialogAction;
	QShortcut* findNextAction;
	QString findString;
	int ftpFileNameID;
	int ftpDownloadID;

    void saveCustomSetting();
    void loadCustomSetting();
    void writePort();	
	int DataDisplayIndex();
	QRadioButton* GetDataDisplayPointer(DATADISPLAY);
	QString EncodebyDataDisplay(QByteArray&);
	QByteArray DecodebyDataDisplay(QString);
	void removeBakFile();

	/* check version */
	void UpdateVersion();
	float GetVersionFromPath(const QString& path);
	bool IsNeedUpdate();
};

#endif // MAINWINDOW_H
